package com.appkubes.mall.restful.application.customer.taobao.controller;

import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.core.controller.BaseMallCustomerTaobaoController;
import com.appkubes.mall.core.entity.MallCustomerTaobao;
import com.appkubes.mall.restful.application.customer.customer.entity.dto.CustomerInfoDTO;
import com.appkubes.mall.restful.application.customer.customer.entity.vo.AdminKeyVO;
import com.appkubes.mall.restful.application.customer.customer.entity.vo.CustomerKeyVO;
import com.appkubes.mall.restful.application.customer.taobao.entity.dto.GoodsCollectDTO;
import com.appkubes.mall.restful.application.customer.taobao.entity.vo.GoodsCollectVO;
import com.appkubes.mall.restful.application.customer.taobao.entity.vo.ModifyAlipayInfoVO;
import com.appkubes.mall.restful.application.customer.taobao.service.impl.CustomerTaobaoServiceImpl;
import com.appkubes.mall.restful.application.customer.taobao.entity.vo.BindPidParamVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Rongjie
 * @Date: 2020/2/27
 * @Description:
 */
@RestController
public class CustomerTaobaoController extends BaseMallCustomerTaobaoController {

    @Autowired
    CustomerTaobaoServiceImpl customerTaobaoService;


    @PostMapping("/userTaobaoInfo")
    @ApiOperation("获取用户信息")
    public Response userTaobaoInfo(@ParamValid CustomerKeyVO param) {
        MallCustomerTaobao userInfo = customerTaobaoService.getCustomerTaobaoInfo(param.getCustomerKey());
        return Response.success(userInfo);
    }

    @PostMapping("/modifyAlipayInfo")
    @ApiOperation("修改支付宝信息")
    public Response modifyAlipayInfo(@ParamValid ModifyAlipayInfoVO param) {
        Boolean res = customerTaobaoService.modifyAlipayInfo(param.getCustomerKey(),param.getAlipayAccount(),param.getAlipayName());
        return Response.success(res);
    }

    /**
     * @param param
     * @return
     */
    @PostMapping("/bindPid")
    @ApiOperation("绑定pid")
    public Response bindPid(@ParamValid BindPidParamVO param) {
        Boolean res = customerTaobaoService.bindPid(param.getCustomerKey(), param.getPid());
        return Response.success(res);
    }

    @PostMapping("/goodsCollectList")
    @ApiOperation("商品收藏列表")
    public Response goodsCollectList(@ParamValid GoodsCollectVO param) {
        Page pageInfo = new Page(param.getPage(), param.getSize());
        List<GoodsCollectDTO> goodsList = customerTaobaoService.goodsCollectList(param.getCustomerKey(), param.getSort(), pageInfo);
        return Response.success(goodsList);
    }
}
